package com.xk.sport.backend.dao.repository;

import com.xk.sport.backend.dao.model.Teacher;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface TeacherDao extends JpaRepository<Teacher, Long>, JpaSpecificationExecutor<Teacher> {
    @Query(value = "select * from teacher where id in (?1)", nativeQuery = true)
    List<Teacher> findTeachersByIds(List<Long> ids);

    @Query(value = "select id from teacher where name like %?1%", nativeQuery = true)
    Long[] findIdsByName(String name);

    @Query(value = "select * from teacher where code = ?1 limit 1", nativeQuery = true)
    Teacher findByCode(String code);
}
